import java.util.Scanner;

public class Fibonacci {
    public static void main(String[] args) {
        System.out.println(fibonacci(5));

    }
    public static int fibonacci(int n) {
        if(n == 0) {
            return 0;
        }
        if(n == 1) {
            return 1;
        }
        int fn = 0;
        int fn1 = 1;
        int fn2 = 0;
        for (int i = 0; i < n; i++) {
            fn = fn1 + fn2;//中间状态
            fn2 = fn1;
            fn1 = fn;
        }
        return fn;
    }
}
